#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str[100];
	int count[26] = { 0 };
	int n = 0;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++)
	{
		getline(cin, str[i]);
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; str[i][j] != '\0'; j++)
		{
			if (str[i][j] != ' ')
				count[str[i][j] - 'a']++;
		}

	}
	int maxcount = 0;
	for (int i = 0; i < 26; i++)
	{
		if (count[i] > maxcount)
		{
			maxcount = count[i];
		}
	}
	for (int i = 0; i < 26; i++)
	{
		if (count[i] == maxcount)
		{
			cout << char(i + 'a') << ' ' << maxcount << endl;
		}
	}
	return 0;
}